package com.baizhi.service.impl;

import com.baizhi.config.log.LogAnnotation;
import com.baizhi.entity.GuruArticle;
import com.baizhi.entity.R;
import com.baizhi.mapper.GuruArticleMapper;
import com.baizhi.service.GuruArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Slf4j
public class GuruArticleServiceImpl implements GuruArticleService {
    @Autowired
    private GuruArticleMapper guruArticleMapper;
    @Transactional
    @LogAnnotation(content = "app查询关注上师文章",type = "select")
    public R selectByGuruId(Integer id) {
        try{
            List<GuruArticle> guruArticles = guruArticleMapper.selectByGuruId(id);
            return R.ok().put("data",guruArticles);
        }catch(Exception e){
            return R.error(1005,"查询关注上师文章失败");
        }
    }

    @Transactional
    @LogAnnotation(content = "app查询所有上师文章",type = "select")
    public R selectAllGuruArticle() {
        try{
            List<GuruArticle> guruArticles = guruArticleMapper.selectAllGuruArticle();
            return R.ok().put("data",guruArticles);
        }catch(Exception e){
            return R.error(1006,"查询所有上师文章失败");
        }
    }
}
